<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('设备型号列表')" />
</head>
<body class="gray-bg">
    <div class="ui-layout-center">
        <div class="container-div">
            <div class="row">
                <div class="col-sm-12 search-collapse">
                    <form id="formId">
                        <input type="hidden" id="deptId" name="deptId">
                        <input type="hidden" id="parentId" name="parentId">
                        <div class="select-list">
                            <ul>
                                <li>
                                    <label>设备型号：</label>
                                    <input type="text" name="model"/>
                                </li>
                                <li>
                                    设备类型：<select name="deviceType" th:with="type=${@dict.getType('snk_device_type')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                                </li>
                                <li>
                                    控制板类型：<select name="type" th:with="type=${@dict.getType('snk_model_type')}">
                                        <option value="">所有</option>
                                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                    </select>
                                </li>
                                <li>
                                    <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                    <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                                </li>
                            </ul>
                        </div>
                    </form>
                </div>
                <div class="btn-group-sm" id="toolbar" role="group">
                    <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="door:model:add">
                        <i class="fa fa-plus"></i> 添加
                    </a>
                    <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="door:model:remove">
                        <i class="fa fa-remove"></i> 删除
                    </a>
                </div>
                <div class="col-sm-12 select-table table-striped">
                    <table id="bootstrap-table"></table>
                </div>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('door:model:edit')}]];
        var removeFlag = [[${@permission.hasPermi('door:model:remove')}]];
        var deviceType = [[${@dict.getType('snk_device_type')}]];
        var port = [[${@dict.getType('snk_model_port')}]];
        var type = [[${@dict.getType('snk_model_type')}]];
        var prefix = ctx + "door/device/model";

        $(function() {
            var options = {
                uniqueId: "id",
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                clickToSelect: true,
                modalName: "设备型号",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'model',
                    title: '设备型号'
                },
                {
                    field: 'deviceType',
                    title: '设备类型',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(deviceType, value);
                    }
                },
                {
                    field: 'port',
                    title: '控制门数量',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(port, value);
                    }
                },
                {
                    field: 'type',
                    title: '控制板类型',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(type, value);
                    }
                },
                {
                    field: 'comment',
                    title: '描述'
                },
                {
                    field: 'image',
                    title: '设备图片',
                    formatter: function(value, row, index) {
                        if ($.common.isEmpty(value)) {
                            return value;
                        }
                        return $.common.sprintf("<img class='img-circle img-xs' data-height='%s' data-width='%s' data-target='%s' src='%s'/>", 'auto', 'auto', 'self', ctx + value.substr(1));
                    }
                },
                {
                    field: 'conScheme',
                    title: '接线图',
                    formatter: function(value, row, index) {
                        if ($.common.isEmpty(value)) {
                            return value;
                        }
                        return $.common.sprintf("<img class='img-circle img-xs' data-height='%s' data-width='%s' data-target='%s' src='%s'/>", 'auto', '65%', 'self', ctx + value.substr(1));
                    }
                },
                {
                    field: 'createBy',
                    title: '创建者'
                },
                {
                    field: 'createTime',
                    title: '创建时间'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

    </script>
</body>
</html>